import request from '@/config/axios'

/** 城市信息 */
export interface City {
          id: number; // ID
          name?: string; // 名称
          sort: number; // 排序
  }

// 城市 API
export const CityApi = {
  // 查询城市分页
  getCityPage: async (params: any) => {
    return await request.get({ url: `/business/city/page`, params })
  },

  // 查询城市详情
  getCity: async (id: number) => {
    return await request.get({ url: `/business/city/get?id=` + id })
  },

  // 查询城市
  getCityAll: async () => {
    return await request.get({ url: `/business/city/all` })
  },

  // 新增城市
  createCity: async (data: City) => {
    return await request.post({ url: `/business/city/create`, data })
  },

  // 修改城市
  updateCity: async (data: City) => {
    return await request.put({ url: `/business/city/update`, data })
  },

  // 删除城市
  deleteCity: async (id: number) => {
    return await request.delete({ url: `/business/city/delete?id=` + id })
  },

  /** 批量删除城市 */
  deleteCityList: async (ids: number[]) => {
    return await request.delete({ url: `/business/city/delete-list?ids=${ids.join(',')}` })
  },

  // 导出城市 Excel
  exportCity: async (params) => {
    return await request.download({ url: `/business/city/export-excel`, params })
  },
}
